1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module soup.Logger;
26 
27 private import glib.ConstructionException;
28 private import gobject.ObjectG;
29 private import soup.Session;
30 private import soup.SessionFeatureIF;
31 private import soup.SessionFeatureT;
32 private import soup.c.functions;
33 public  import soup.c.types;
34 
35 
36 /** */
37 public class Logger : ObjectG, SessionFeatureIF
38 {
39 	/** the main Gtk struct */
40 	protected SoupLogger* soupLogger;
41 
42 	/** Get the main Gtk struct */
43 	public SoupLogger* getLoggerStruct(bool transferOwnership = false)
44 	{
45 		if (transferOwnership)
46 			ownedRef = false;
47 		return soupLogger;
48 	}
49 
50 	/** the main Gtk struct as a void* */
51 	protected override void* getStruct()
52 	{
53 		return cast(void*)soupLogger;
54 	}
55 
56 	/**
57 	 * Sets our main struct and passes it to the parent class.
58 	 */
59 	public this (SoupLogger* soupLogger, bool ownedRef = false)
60 	{
61 		this.soupLogger = soupLogger;
62 		super(cast(GObject*)soupLogger, ownedRef);
63 	}
64 
65 	// add the SessionFeature capabilities
66 	mixin SessionFeatureT!(SoupLogger);
67 
68 
69 	/** */
70 	public static GType getType()
71 	{
72 		return soup_logger_get_type();
73 	}
74 
75 	/**
76 	 * Creates a new #SoupLogger with the given debug level. If @level is
77 	 * %SOUP_LOGGER_LOG_BODY, @max_body_size gives the maximum number of
78 	 * bytes of the body that will be logged. (-1 means "no limit".)
79 	 *
80 	 * If you need finer control over what message parts are and aren't
81 	 * logged, use soup_logger_set_request_filter() and
82 	 * soup_logger_set_response_filter().
83 	 *
84 	 * Params:
85 	 *     level = the debug level
86 	 *     maxBodySize = the maximum body size to output, or -1
87 	 *
88 	 * Returns: a new #SoupLogger
89 	 *
90 	 * Throws: ConstructionException GTK+ fails to create the object.
91 	 */
92 	public this(SoupLoggerLogLevel level, int maxBodySize)
93 	{
94 		auto __p = soup_logger_new(level, maxBodySize);
95 
96 		if(__p is null)
97 		{
98 			throw new ConstructionException("null returned by new");
99 		}
100 
101 		this(cast(SoupLogger*) __p, true);
102 	}
103 
104 	/**
105 	 * Sets @logger to watch @session and print debug information for
106 	 * its messages.
107 	 *
108 	 * (The session will take a reference on @logger, which will be
109 	 * removed when you call soup_logger_detach(), or when the session is
110 	 * destroyed.)
111 	 *
112 	 * Deprecated: Use soup_session_add_feature() instead.
113 	 *
114 	 * Params:
115 	 *     session = a #SoupSession
116 	 */
117 	public void attach(Session session)
118 	{
119 		soup_logger_attach(soupLogger, (session is null) ? null : session.getSessionStruct());
120 	}
121 
122 	/**
123 	 * Stops @logger from watching @session.
124 	 *
125 	 * Deprecated: Use soup_session_remove_feature() instead.
126 	 *
127 	 * Params:
128 	 *     session = a #SoupSession
129 	 */
130 	public void detach(Session session)
131 	{
132 		soup_logger_detach(soupLogger, (session is null) ? null : session.getSessionStruct());
133 	}
134 
135 	/**
136 	 * Sets up an alternate log printing routine, if you don't want
137 	 * the log to go to <literal>stdout</literal>.
138 	 *
139 	 * Params:
140 	 *     printer = the callback for printing logging output
141 	 *     printerData = data to pass to the callback
142 	 *     destroy = a #GDestroyNotify to free @printer_data
143 	 */
144 	public void setPrinter(SoupLoggerPrinter printer, void* printerData, GDestroyNotify destroy)
145 	{
146 		soup_logger_set_printer(soupLogger, printer, printerData, destroy);
147 	}
148 
149 	/**
150 	 * Sets up a filter to determine the log level for a given request.
151 	 * For each HTTP request @logger will invoke @request_filter to
152 	 * determine how much (if any) of that request to log. (If you do not
153 	 * set a request filter, @logger will just always log requests at the
154 	 * level passed to soup_logger_new().)
155 	 *
156 	 * Params:
157 	 *     requestFilter = the callback for request debugging
158 	 *     filterData = data to pass to the callback
159 	 *     destroy = a #GDestroyNotify to free @filter_data
160 	 */
161 	public void setRequestFilter(SoupLoggerFilter requestFilter, void* filterData, GDestroyNotify destroy)
162 	{
163 		soup_logger_set_request_filter(soupLogger, requestFilter, filterData, destroy);
164 	}
165 
166 	/**
167 	 * Sets up a filter to determine the log level for a given response.
168 	 * For each HTTP response @logger will invoke @response_filter to
169 	 * determine how much (if any) of that response to log. (If you do not
170 	 * set a response filter, @logger will just always log responses at
171 	 * the level passed to soup_logger_new().)
172 	 *
173 	 * Params:
174 	 *     responseFilter = the callback for response debugging
175 	 *     filterData = data to pass to the callback
176 	 *     destroy = a #GDestroyNotify to free @filter_data
177 	 */
178 	public void setResponseFilter(SoupLoggerFilter responseFilter, void* filterData, GDestroyNotify destroy)
179 	{
180 		soup_logger_set_response_filter(soupLogger, responseFilter, filterData, destroy);
181 	}
182 }